home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Prefs / MPPMonitorList.c < prev    next >
C/C++ Source or Header  |  1998-10-16  |  3KB  |  114 lines

  1. #include "mpp.h"
  2.  
  3. void CreateMonitorList(struct List *List);
  4. struct ModeNode *CreateMonitorNode(ULONG ID);
  5.  
  6. ULONG SelectMonitor(struct DefaultNode *DN)
  7. {
  8.   struct List monlist;
  9.   struct ModeNode *mn;
  10.   LONG   item;
  11.   ULONG rv=INVALID_ID;
  12.   UBYTE listtitle[100];
  13.   
  14.   sprintf(listtitle,GetString(MSG_REQ_SELECT_MONITOR_FOR),DN->Def_Node.ln_Name);
  15.  
  16.   NewList(&monlist);  
  17.   CreateMonitorList(&monlist);
  18.  
  19.   item=SelectReq(&monlist,listtitle);
  20.   
  21.   if(item>=0)
  22.   {
  23.     mn=(struct ModeNode *)monlist.lh_Head;
  24.     while(item)
  25.     {
  26.       mn=(struct ModeNode *)mn->mn_Node.ln_Succ;
  27.       item--;
  28.     }
  29.     rv=mn->mn_DisplayID;
  30.     DN->ModeID=rv;
  31.   }
  32.   FreeNameNodes(&monlist);
  33.  
  34.   return(rv);
  35. }
  36.  
  37. void CreateMonitorList(struct List *List)
  38. {
  39.   struct ModeNode    *mn;
  40.   ULONG previd=(INVALID_ID & MONITOR_ID_MASK),
  41.         id,mid;
  42.   
  43.   id=NextDisplayInfo(INVALID_ID);
  44.  
  45.   while(id!=INVALID_ID)
  46.   {
  47.     mid=id & MONITOR_ID_MASK;
  48.     if(previd!=mid && mid)
  49.     { // if the monitor id is different and not 0 then make a node .
  50.       previd=mid;
  51.       if(mn=CreateMonitorNode(id))
  52.         EnqueueName(List,(struct Node *)mn);      
  53.     } 
  54.     id=NextDisplayInfo(id);
  55.   }
  56.   
  57.   if(mn=CreateMonitorNode(INVALID_ID))//                                                               (4.57.4)
  58.   { //                                                                                                 (4.57.4)
  59.     AddHead(List,(struct Node *)mn);      //                                                           (4.57.4)
  60.   }  //                                                                                                (4.57.4)
  61. }
  62.  
  63. struct ModeNode *CreateMonitorNode(ULONG ID)//                                                         (4.57.8)
  64. {
  65.   struct ModeNode *mn;
  66.   struct MonitorInfo mi;
  67.  
  68.   if(mn=AllocVec(sizeof(struct ModeNode),MEMF_PUBLIC|MEMF_CLEAR))
  69.   {
  70.     mn->mn_DisplayID=ID;
  71.     if(mn->mn_Node.ln_Name=AllocVec(64,MEMF_PUBLIC))
  72.     {
  73.       if(GetMonitorName(ID,mn->mn_Node.ln_Name,64))
  74.       {
  75.         return(mn);
  76.       }
  77.       FreeVec(mn->mn_Node.ln_Name);
  78.     }
  79.     FreeVec(mn);   
  80.   }       
  81.   return(0);
  82. }
  83.  
  84. /*
  85. struct ModeNode *CreateMonitorNode(ULONG ID)
  86. {
  87.   struct ModeNode *mn;
  88.   struct MonitorInfo mi;
  89.  
  90.   if(mn=AllocVec(sizeof(struct ModeNode),MEMF_PUBLIC|MEMF_CLEAR))
  91.   {
  92.     mn->mn_DisplayID=ID;
  93.     if(ID & MONITOR_ID_MASK == MONITOR_ID_MASK)//                                                      (4.57.5)
  94.     {//                                                                                                (4.57.5)
  95.       if(mn->mn_Node.ln_Name=CopyString(GetString(MSG_ANY_MONITOR),MEMF_PUBLIC))//                     (4.57.5)
  96.       {//                                                                                              (4.57.5)
  97.         return(mn);//                                                                                  (4.57.5)
  98.       }//                                                                                              (4.57.5)
  99.     }//                                                                                                (4.57.5)
  100.     else
  101.     {
  102.       if(GetDisplayInfoData(NULL,(UBYTE *)&mi,sizeof(struct MonitorInfo),DTAG_MNTR,ID)>0)
  103.       {
  104.         if(mi.Mspc)
  105.           if(mn->mn_Node.ln_Name=CopyString(mi.Mspc->ms_Node.xln_Name,MEMF_PUBLIC))
  106.             return(mn);
  107.       }
  108.     }
  109.     FreeVec(mn);   
  110.   }       
  111.   return(0);
  112. }
  113.  
  114. */